package io.gitee.mingbaobaba.apijson.querycondition.query.conditions;

import org.springframework.util.CollectionUtils;

/**
 * <p>查询列片段</p>
 */
class ProjectionSegment implements DslSegment {

    @Override
    public void apply(AbstractBaseWrapper<?, ?, ?> wrapper) {
        if (CollectionUtils.isEmpty(wrapper.columnList) && wrapper.getEntityClass() != null) {
            Class<?> entityClass = wrapper.getEntityClass();
            @SuppressWarnings("rawtypes")
            Class cast = entityClass;
            wrapper.select(cast);
        }
        wrapper.apiJsonParams.put(EnumApiJson.COLUMN.getCode(), SegmentJoiner.join(";", wrapper.columnList));
    }
}

